﻿using Mes.Domain.BoundedContext.Entities.WorkOrders;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.WorkOrders
{
    public class ItemProdEntityConfig : IEntityTypeConfiguration<ItemProd>
    {
        public void Configure(EntityTypeBuilder<ItemProd> builder)
        {
            builder.ToTable("item_prod");
            builder.HasKey(b => new { b.Row_Id });
            builder.Property(b => b.Wo_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Oper_Id).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Shift_Start_Utc).IsRequired();
            builder.Property(b => b.Shift_Start_Local).IsRequired();
            builder.Property(b => b.Hour_Start_Utc).IsRequired();
            builder.Property(b => b.Hour_Start_Local).IsRequired();
            builder.Property(b => b.Item_Id).IsRequired();
            builder.Property(b => b.Lot_No).HasMaxLength(40);
            builder.Property(b => b.Rm_Lot_No).HasMaxLength(40);
            builder.Property(b => b.Sublot_No).HasMaxLength(40);
            builder.Property(b => b.Rm_Sublot_No).HasMaxLength(40);
            builder.Property(b => b.Reas_Cd).IsRequired();
            builder.Property(b => b.User_Id).IsRequired().HasMaxLength(40);
            builder.Property(b => b.Ent_Id).IsRequired();
            builder.Property(b => b.Shift_Id).IsRequired();
            builder.Property(b => b.Grade_Cd).IsRequired();
            builder.Property(b => b.Status_Cd).IsRequired();
            builder.Property(b => b.To_Ent_Id);
            builder.Property(b => b.Good_Prod).IsRequired();
            builder.Property(b => b.Qty_Prod).IsRequired();
            builder.Property(b => b.Qty_Prod_Erp).IsRequired();
            builder.Property(b => b.Processed_Flag).IsRequired();
            builder.Property(b => b.Byproduct);
            builder.Property(b => b.Ext_Ref).HasMaxLength(40);
            builder.Property(b => b.Move_Status).IsRequired();
            builder.Property(b => b.Genealogy_Id).HasMaxLength(254);
            builder.Property(b => b.Event_Id).HasMaxLength(80);
            builder.Property(b => b.Segment_Requirement_Id).HasMaxLength(80);
            builder.Property(b => b.Segment_Response_Id).HasMaxLength(80);
            builder.Property(b => b.Comments).HasMaxLength(254);
            builder.Property(b => b.Spare1).HasMaxLength(80);
            builder.Property(b => b.Spare2).HasMaxLength(80);
            builder.Property(b => b.Spare3).HasMaxLength(80);
            builder.Property(b => b.Spare4).HasMaxLength(80);
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40);
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Created_At_Utc).IsRequired();
            builder.Property(b => b.Created_At_Local).IsRequired();
            builder.Property(b => b.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
